unit uTyres.local;

interface

uses uDebug.common, uDefs.local;

type
 //================================ TYRES
  TTyreItem = record
    TyreID   : integer;
    Name     : string;
    DryGrip  : integer;
    WearRate : integer;
    TOZ      : integer;
  end;
  TTyreItems = array of TTyreItem;

  TTyreList = class( TObject )
  private
    m_Items : TTyreItems;
  public
    Count : integer;

    property Items : TTyreItems read m_Items;

    constructor Create;
    destructor Destroy; override;

    procedure Add(nTyreID:integer;nName:string;nDry,nWear,nTOZ:integer);
    procedure Clear;

    function TyreEffect(TyreTOZ, CurrentWeather:integer): integer;

  end;

implementation

  //================================ TYRES
constructor TTyreList.Create;
begin
  inherited Create;

  Count := 0;
  SetLength( m_Items, Count );
end;
destructor TTyreList.Destroy;
begin
  Count := 0;

  SetLength( m_Items, Count );

  inherited Destroy;
end;
procedure TTyreList.Add( nTyreID:integer;nName:string;nDry,nWear,nTOZ:integer);
begin
  DevConsole.Msg(ES_DEBUG, 'Adding Tyre '+nName);

  Inc( Count );
  SetLength( m_Items, Count );

  with m_Items[ Count-1 ] do
  begin
    TyreID   := nTyreID;
    Name     := nName;
    DryGrip  := nDry;
    WearRate := nWear;
    TOZ      := nTOZ;
  end;
end;
procedure TTyreList.Clear;
begin
  Count := 0;
  SetLength( m_Items, Count );
end;
function TTyreList.TyreEffect(TyreTOZ, CurrentWeather:integer): integer;
begin
  if (TyreTOZ < CurrentWeather) then
    result := CurrentWeather - TyreTOZ
  else
    result := TyreTOZ - CurrentWeather;

{  if (result < 1) then
    result := 1
  else
  if (result > MAX_WEATHER) then
    result := MAX_WEATHER;}
end;

end.
